package app;

import android.app.Application;

import user.LoginUser;
import greendao.DaoMaster;
import greendao.DaoSession;

/**
 * Created by 任科全 on 2017/3/13.
 */

public class MyApplication extends Application {
    static MyApplication mMyApplication;
    private static LoginUser mLoginUser;

    DaoMaster.DevOpenHelper devOpenHelper;
    DaoMaster mDaoMaster;
    static DaoSession mDaoSession;

    @Override
    public void onCreate() {
        super.onCreate();
        Init();
        InitDB();

    }

    public void Init(){
        mLoginUser=new LoginUser();
        mMyApplication=this;
    }

    public void InitDB() {
        devOpenHelper = new DaoMaster.DevOpenHelper(MyApplication.getInstance(), "TheLine", null);
        mDaoMaster = new DaoMaster(devOpenHelper.getWritableDb());
        mDaoSession = mDaoMaster.newSession();
    }

    public static MyApplication getInstance() {
        return mMyApplication;
    }

    public static LoginUser getmLoginUser() {
        return mLoginUser;
    }

    public static void setmLoginUser(LoginUser mLoginUser) {
        MyApplication.mLoginUser = mLoginUser;
    }

    public static DaoSession getDaoSession() {
        return mDaoSession;
    }


}
